//
//  WmcInfoDelegate.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/6/7.
//

import UIKit

// MARK: - [WmcInfoDelegate]

/// 信息代理
/// 主要用于获取水印相机接口或者一些特定参数
public protocol WmcInfoDelegate: NSObjectProtocol {
    func photoIsUploadCloudAlbum(_ attribute: WmcAttribute, photoResult: YPWmcManager.PhotoResult) -> Bool

    func videoIsUploadCloudAlbum(_ attribute: WmcAttribute, videoResult: YPWmcManager.VideoResult) -> Bool
}

// MARK: - 驱动方法

public extension WmcInfoDelegate {
    /// 用户是否是第一次拍照
    /// - Parameters:
    ///   - block: 结果
    func wmc_userTakePhotoIsFirst(_ block: @escaping YPBlock.OneParam<Bool>) {
        YPWmcDrivingManager.userTakePhotoIsFirst(block)
    }

    /// 获取今天里，本地相册的媒体
    /// - Parameters:
    ///   - mediaType: 媒体类型
    ///   - day: 某一天
    ///   - success: 成功结果
    ///   - failure: 失败结果
    func wmc_localAlbumTodayMediaList(mediaType: [WmcMedia.MediaType],
                                      success: YPBlock.OneParam<[WmcMedia]>? = nil,
                                      failure: YPBlock.OneParam<YPWmcError>? = nil)
    {
        YPWmcDrivingManager.localAlbumTodayMediaList(mediaType: mediaType, success: success, failure: failure)
    }

    /// 获取某一天里，本地相册的媒体
    /// - Parameters:
    ///   - mediaType: 媒体类型
    ///   - day: 某一天
    ///   - success: 成功结果
    ///   - failure: 失败结果
    func wmc_localAlbumMediaList(mediaType: [WmcMedia.MediaType],
                                 day: Date,
                                 success: YPBlock.OneParam<[WmcMedia]>? = nil,
                                 failure: YPBlock.OneParam<YPWmcError>? = nil)
    {
        YPWmcDrivingManager.localAlbumMediaList(mediaType: mediaType,
                                                day: day,
                                                success: success,
                                                failure: failure)
    }

    /// 获取某段时间里，本地相册的媒体
    /// - Parameters:
    ///   - mediaType: 媒体类型
    ///   - startDate: 起始时间
    ///   - endDate: 终止时间
    ///   - success: 成功结果
    ///   - failure: 失败结果
    func wmc_localAlbumMediaList(mediaType: [WmcMedia.MediaType],
                                 startDate: Date,
                                 endDate: Date,
                                 success: YPBlock.OneParam<[WmcMedia]>? = nil,
                                 failure: YPBlock.OneParam<YPWmcError>? = nil)
    {
        YPWmcDrivingManager.localAlbumMediaList(mediaType: mediaType,
                                                startDate: startDate,
                                                endDate: endDate,
                                                success: success,
                                                failure: failure)
    }

    /// 获取所有本地相册的媒体
    /// - Parameters:
    ///   - mediaType: 媒体类型
    ///   - page: 分页
    ///   - pageSize: 分页大小
    ///   - success: 成功结果
    ///   - failure: 失败结果
    func wmc_localAlbumAllMediaList(mediaType: [WmcMedia.MediaType],
                                    page: Int = 1,
                                    pageSize: Int = 200,
                                    success: YPBlock.OneParam<[WmcMedia]>? = nil,
                                    failure: YPBlock.OneParam<YPWmcError>? = nil)
    {
        YPWmcDrivingManager.localAlbumAllMediaList(mediaType: mediaType,
                                                   page: page,
                                                   pageSize: pageSize,
                                                   success: success,
                                                   failure: failure)
    }

    /// 保存图片到相册
    /// - Parameters:
    ///   - photoResult: 照片结果
    ///   - uploadToCloudAlbum: 是否上传到云相册
    func wmc_savePhotoToLocalAlbum(photoResult: YPWmcManager.PhotoResult) {
        YPWmcDrivingManager.shared.home_savePhotoToLocalAlbumBlock?(photoResult)
    }

    /// 上传视频到云相册
    /// - Parameters:
    ///   - photoResult: 照片结果
    ///   - uploadToCloudAlbum: 是否上传到云相册
    func wmc_uploadVideoToLocalAlbum(videoResult: YPWmcManager.VideoResult) {
        YPWmcDrivingManager.shared.home_uploadVideoToLocalAlbumBlock?(videoResult)
    }
}

public extension WmcInfoDelegate {
    func photoIsUploadCloudAlbum(_ attribute: WmcAttribute, photoResult: YPWmcManager.PhotoResult) -> Bool {
        return true
    }

    func videoIsUploadCloudAlbum(_ attribute: WmcAttribute, videoResult: YPWmcManager.VideoResult) -> Bool {
        return true
    }
}
